﻿ //Console.WriteLine("输入你要存多少钱：");
            //float a = float.Parse(Console.ReadLine());
           


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {


            float count = 1;
            float sum = 0;
            bool flag = true;
            while (flag) {
                try
                {
                    Console.WriteLine("请输入考生成绩");
                    float score = float.Parse(Console.ReadLine());
                    sum += score;

                    b: Console.WriteLine("年轻人，你是否想继续前行");
                    string str = Console.ReadLine();

                    switch (str)
                    {
                        case "是":
                        case "1":
                            count++;
                            break;
                        case "否":
                        case "0":
                        case "不":
                        case "不要":
                        case "不想":
                        case "不了":
                            flag = false;
                            break;
                        default:
                            Console.WriteLine("输入错误");
                            goto b;
                    }
                    
                }
                catch (FormatException f)
                {
                    Console.WriteLine(f.Message);
                    Console.WriteLine("输入错误");
                }
                catch (OverflowException o)
                {
                    Console.WriteLine(o.Message);
                    Console.WriteLine("数值溢出");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                finally {
                    if (!flag)
                    {
                        float avg = sum / count;
                        Console.WriteLine($"总学生数:{count}");
                        Console.WriteLine($"总成绩:{sum}");
                        Console.WriteLine($"平均分:{avg}");
                        Console.WriteLine("一切都将结束。");
                    }
                    
                }

            }

         float money = 0;
            while (true)
            {
                Console.WriteLine("1、存款，  2、取款");
                int key = int.Parse(Console.ReadLine());

                switch (key)
                {
                    case 1:
                        Console.WriteLine("请输入你要存多少钱");
                        float a = float.Parse(Console.ReadLine());
                        money += a;
                        break;
                    case 2:
                        try
                        {
                            Console.WriteLine("请输入你要取得金额");
                            float b = float.Parse(Console.ReadLine());
                            if (money - b < 0)
                            {
                                throw new ArgumentOutOfRangeException("取款金额大于余额，请重新输入");

                            }
                            else
                            {
                                money -= b;
                                Console.WriteLine("取款成功");
                                Console.WriteLine(money);

                            }
                        }
                        catch (Exception e)
                        {

                            Console.WriteLine(e.Message);
                        }
                        break;
                    default:
                        break;
                }

            }

        }
    }
}